# 简道中需求 和 迭代规划需求 的比对，
from openpyxl import load_workbook

def compare_excel_fields(file1, file2, field_name):
    # 加载两个 Excel 文件
    wb1 = load_workbook(file1)
    wb2 = load_workbook(file2)
    field_data1 = set()
    field_data2 = set()

    sheet1 = wb1.active
    for row in sheet1.iter_rows(min_row=0, max_col=sheet1.max_column, max_row=sheet1.max_row):
        if row[0].value is not None:
            field_data1.add(row[0].value)
    # print(field_data1)

    # 获取第二个表格的指定字段数据
    sheet2 = wb2.active
    for row in sheet2.iter_rows(min_row=0, max_col=sheet2.max_column, max_row=sheet2.max_row):
        if row[0].value is not None and row[6].value == '待开发':
            field_data2.add(row[0].value)
    #print(field_data2)

    # 对比两个数据集的差异
    diff = set(field_data2).difference(set(field_data1))

    # 输出差异点
    print("差异点：")
    for item in diff:
        print(item)

# 示例用法
compare_excel_fields("/Users/zhangxiangbin/Desktop/request/2023工作记录.xlsx", "/Users/zhangxiangbin/Desktop/request/2023招商平安资产核心管理系统常规需求项目故事导出.xlsx", "故事ID")
